class MinStack(object):

    def __init__(self):
        self.l = []
        self.m = []

    def push(self, val):
        """
        :type val: int
        :rtype: None
        """
        self.l.append(val)
        if not self.m or self.m[-1] > val:
            self.m.append(val)
        else:
            self.m.append(self.m[-1])

    def pop(self):
        """
        :rtype: None
        """
        val = self.l[-1]
        self.l = self.l[:-1]
        self.m = self.m[:-1]

    def top(self):
        """
        :rtype: int
        """
        return self.l[-1]

    def getMin(self):
        """
        :rtype: int
        """
        return self.m[-1]
